import React from 'react'
import { Button, Icon } from 'antd'
import { connect } from 'dva'
// import router from 'umi/router';
import Dialog from '@/components/Dialog'
// import Link from 'umi/link'

export default connect(({ app: { user } }) => ({
	user
}))(props => {
	const {
		user = {},
		dispatch
	} = props
	const handleQuit = e => {
		Dialog.confirm({
			title: '确认操作',
			content: '确定要退出登录吗？',
			onOk() {
				dispatch({
					type: 'app/logout'
				})
			}
		})
	}
	return (
		<div className="header">
			<div className="header-toolbar">
				<div className="fl tools">
					<ul>
						<li><span className="ico-button">信用平台管理系统</span></li>
					</ul>
				</div>
				<div className="fr tools">
					<ul>
						{/*<li><Link to="/login"><Icon type="poweroff" /> <span>退出</span></Link></li>*/}
						<li><Icon type="user" /> <span>{user.name}</span></li>
						<li><Button type="link" icon="poweroff" onClick={handleQuit}>退出</Button></li>
					</ul>
				</div>
			</div>
		</div>
	)
})